; Disassembly of machine code "Maze Avenger.bin"
; (C)October 31, 1984 Dale Low, Victoria BC, CAN
; type-in AB program in Arcadian Vol. 6, pg. 100
; 
; CPU Type: Z80 running either Bally or Astro Basic
;
; Created with dZ80 2.0 using script "BallyHVG.LUA"
; on Monday, 07 of March 2011 at 05:44 PM by R.C.D.
; 
; Assembles correctly with "zmac -i -m MAZEAV~1.asm"
;
; Program listing and Comment block down below END
;

; defines from "HVGLIB.H"
SYSSUK  macro   NUMBR
        RST     $38
        DB      NUMBR + 1
        endm
        ;
CHRDIS  EQU     $32

        ORG 20237

; ********* called by CALLB from AstroBasic ***
L4F0D:  LD      IX,L4F22        ; point IndeX to A.F.D. below
        PUSH    DE
        SYSSUK  CHRDIS          ; UPI CHaRacter DISplay [to ERASE old]
        DB      $66             ; ... X = 102  [XY pointed to by variable D]
        DB      $3A             ; ... Y = 58
        DB      $28             ; ... Options = 40  [1x X-ORed Color 2 on Color 0]
        DB      $80             ; ... Character = 128  [pointed to by variable T]
        ;
        NOP                     ; hi byte of %(T) = 0
        SYSSUK  CHRDIS          ; UPI CHaRacter DISplay [to DRAW new]
        DB      $66             ; ... X = 102  [XY pointed to by variable C]
        DB      $3A             ; ... Y = 58
        DB      $28             ; ... Options = 40  [1x X-ORed Color 2 on Color 0]
        DB      $80             ; ... Character = 128  [pointed to by variable S]
        ;
        NOP                     ; hi byte of %(S) = 0
        POP     DE
        RET                     ; -urn to Basic

; ========= Alternate Font Descriptor block ===
L4F22:
        DB      $80             ; FonT BASE character
        DB      $00             ; FonT Frame Size X width
        DB      $00             ; FonT Frame Size Y height
        DB      $01             ; FonT X size for char in BYTEs
        DB      $06             ; FonT Y SIZe height in rows
        DW      L4F29           ; FonT Pattern Table address

; ====== Character #80 for EVEN draws ===
; only TWO pixels in Robot Arms exchange position
L4F29:  DB      $0C             ; . . . . X X . .
        DB      $1E             ; . . . X X X X .
        DB      $0D             ; . . . . X X . X
        DB      $3F             ; . . X X X X X X
        DB      $2C             ; . . X . X X . .
        DB      $12             ; . . . X . . X .

  ; === Character #81 for ODD draws ===
        DB      $0C             ; . . . . X X . .
        DB      $1E             ; . . . X X X X .
        DB      $2C             ; . . X . X X . .
        DB      $3F             ; . . X X X X X X
        DB      $0D             ; . . . . X X . X
        DB      $12             ; . . . X . . X .

;L4F35:
        DB      $21             ; -223 [Not used !]
        DB      $FF

        END

; Maze Avenger by Dale Low, 3020 Cook St., Victoria BC, V8T 3S9 CANADA
; 1750 Characters ["Maze Avenger.prg" used only 1746, for a free SZ=54]

note: Missing B=20237;C=20251;D=20244;S=20254;T=20247
Also needs K=127, else ASCII 0 to 127 will display for the first cycle.
Needs free SZ=40 or more [for ten Points=*() and five X=@(),Y=@() pairs]
Initial Erase-Character-80 location in %(D) set to X=-15, Y=-40 by line 5

1 P=0;Z=3;L=Z;W=2;U=2
[Points=0, Z=(2 x 2)-1, Lives=3, W&U=frUit]
2 Y=-10;X=0
[initial XY]
5 clear ;%(D)=-9999
[first Erase off-screen]
6 box 0,-5,150,76,1;box 0,-5,145,70,2
7 box 0,-30,2,20,1;box 0,-20,28,2,1;box 0,10,2,20,1;box 0,20,28,2,1
8 box -37,-10,47,2,1;box 36,-10,47,2,1;box 59,-15,2,12,1;box -59,-15,2,12,1
9 box -14,0,2,20,1;box 14,0,2,20,1;box -30,25,2,10,1;box 30,25,2,10,1
10 box -30,5,2,10,1;box 30,5,2,10,1;box -36,10,14,2,1;box 36,10,14,2,1
11 box -62,0,25,2,1;box 62,0,25,2,1;box -53,20,14,2,1;box 53,20,14,2,1
12 box -59,15,2,10,1;box 59,15,2,10,1;box -51,-30,16,2,1;box 51,-30,16,2,1
14 box -44,-25,2,10,1;box 44,-25,2,10,1
15 box -29,-25,2,10,1;box 29,-25,2,10,1;box -23,-30,14,2,1;box 23,-30,14,2,1
[maze drawn]
20 for A=0to Z;*(A)=rnd (9);next A
[*(fruit x 2) points = 1 to 9]
[*(fruit x 2)+1 set but Not used]
21 for A=0to Zstep 2;@(A)=rnd (10)mul 15-82
[@(X location) = -67 to 68]
22 @(A+1)=rnd (7)mul 10-45;next A
[@(Y location) = -35 to 25]
23 for A=0to Zstep 2;CX=@(A);CY=@(A+1);TV=99+rnd (4);next A
[place fruit 100 to 103]
90 for Q=1to 2;X=X+((JX(1)=1)mul (PX(X+4,Y)=0))-((JX(1)=-1)mul (PX(X-4,Y)=0))
100 Y=Y+((JY(1)=1)mul (PX(X,Y+4)=0))-((JY(1)=-1)mul (PX(X,Y-4)=0));next Q
[move 2 pixels if possible]
105 K=K+1;if K>129K=128
[toggle robot arms]
106 %(S)=K
[for Draw character]
110 gosub 111;goto 169
[move robot and continue]
111 if Y>26Y=26
112 if X>68X=68
113 if X<-68X=-68
120 if Y<-37Y=-37
[limit XY to playfield]
130 H=X+76;V=ABS(Y-40);%(C)=Vmul 256+H;CALLB;%(D)=%(C);%(T)=%(S);return
[display robot at relative location]
169 MU=10;if rnd (30-U)=1goto 700
[footstep, time to die?]
170 if TR(1)=0goto 90
[else fire]
180 MU=88;F=JY(1)mul 3;G=JX(1)mul 3;I=X+G;J=Y+F;for Q=1to 80
[bullet direction and start location]
230 I=I+Gmul 2;J=J+Fmul 2
[new bullet location]
235 for A=0to Zstep 2
236 if *(A)if I+7>@(A)if I-7<@(A)if J+5>@(A+1)if J-5<@(A+1)goto 500
[check for shot fruit]
237 next A
240 box I,J,2,2,3;box I,J,2,2,3
[bullet blip - moved it up to line 233]
250 if (PX(I,J))+(PX(I+2,J))+(PX(I-2,J))+(PX(I,J+2))+(PX(I,J-2))Q=81
[stop bullet at walls]
260 next Q;MU=82;MU=85;goto 90
[loop to move robot]
500 for M=99to 80step -2;MU=M;MU=M+2;MU=M+4;next M
[shot fruit munch sound]
505 box @(A),@(A+1),10,8,2;CX=@(A);CY=@(A+1);TV=*(A)+48
[erase fruit (and any part of robot) then show points]
510 P=P+*(A);*(A)=0;for M=1to 500;next M;box @(A),@(A+1),10,8,2;W=W-1;if W#0goto 530
[bump score, fruit gone, delay, erase points, check for last fruit]
520 U=U+(U<5);Z=Umul 2-1;W=U;P=P+27;for A=79to 99;MU=A;MU=A+2;MU=A+4;next A;goto 20
[new screen, bump fruit to max 5, (fruit x 2)-1 to max 9, doWncount=fruit]
[add bonus screen points WITHOUT UPDATING SCORE, sound sweep, next screen]
530 CY=40;CX=0;print #0,P;Q=81;goto 237
[else more fruit this screen, show new score, stop bullet]
700 NT=9;MU=83;MU=73;MU=63;NT=1
[killer box warning sound]
710 M=7;N=5;A=0
[starting location]
720 A=A+1;if A>25goto 90
[loop counter exit check]
730 M=M+(rnd (3)-2)mul 14;N=N+(rnd (3)-2)mul 10
[move box X +/- 14, Y +/- 10]
740 M=M+(M<-65)mul 14-(M>65)mul 14
[limit box X from -65 to 65]
745 N=N+(N<-35)mul 10-(N>25)mul 10
[limit box Y from -35 to 25]
750 box M,N,5,5,3;box M,N,5,5,3
[box blip - split to line 775]
770 X=X+JX(1)mul 9;Y=Y+JY(1)mul 9;gosub 111
[move robot X +/- 9, Y +/- 9, limit and display]
790 if M>X-29if M<X+29if N<Y+29if N>Y-29for Q=1to 2;line M,N,0;line X,Y,3;next Q;L=L-1;goto (L=0)mul 800+90
[kill if within 28 pixels, dec lives, if any left GOTO 90]
795 goto 720

[change 505 CX=@(A)+2;CY=@(A+1);TV=32;CX=CX-8;TV=*(A)+48]
[510 P=P+*(A);*(A)=0;for M=1to 500;next M;CX=CX-6;TV=32;gosub 530;W=W-1;if W#0Q=81;goto 237]
[520 U=U+(U<5);Z=Umul 2-1;W=U;P=P+27;for A=79to 99;MU=A;MU=A+2;MU=A+4;next A;gosub 530;goto 20]
[530 CY=40;CX=0;print #0,P;return ]
[add 890 PRINT "YOU DIED!]

Machine Code in the L.I.B. %(locations) stuffed with:
 
db $dd,$21,$22,$4f,$d5,$ff,$33,$66,$3a,$28,$80,$00,$ff,$33,$66,$3a
db $28,$80,$00,$d1,$c9,$80,$00,$00,$01,$06,$29,$4f,$0c,$1e,$0d,$3f
db $2c,$12,$0c,$1e,$2c,$3f,$0d,$12,$21,$ff,$00,$00,$00,$00,$00,$00
